const app = '/lesson-admin'

onload =() =>{
    document.querySelector('#loginBtn').onclick = login;
}
function login(){
    let usernameIpt = document.querySelector('#usernameIpt');
    let passwordIpt = document.querySelector('#passwordIpt');
    if(usernameIpt.value && passwordIpt.value){
        console.log(usernameIpt.value,passwordIpt.value);
        let  data={
            'username':usernameIpt.value,
            'password':passwordIpt.value
        }
        ajax({
            'url':app+'/api/v1/user/login',
            'type':'post',
            'data':data,
            'success':res=>{
                if(res.code>0){
                    sessionStorage.setItem('admin',JSON.stringify(res.data));
                    location.href = 'view/main.html';
                }else alert(res.massage)

            }
        });
    }else alert('账号密码为空！')
}